<?php 

/*
* This script is part of "Myitkyina, BBCode-Ready Free/Libre Project Web Hosting Application Form For Popular PHP Forums" 
* Download and more info: http://www.mybehs.org/wiki/MyBEHS:Scripts
* Code maintainer : Victor San Kho Lin<victorlin21@gmail.com>
* Code contributers : {ok list yours here}


    Myitkyina, BBCode-Ready Free/Libre Project Web Hosting Application Form For Popular PHP Forums
    Copyright (C) 2007  Victor San Kho Lin

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


/* It's Hell, need to do better than this of course!! */

/*
* Global Include
*
*/
include 'include/config.php';
include 'include/function.php'; 
include 'header.php';

/*
* Validation $later$
*
*/

/*
while(list($key,$val)=each($_POST)){
$key = $val;
	if(empty($key)){
	echo "Error, one or more fields empty!";
	echo "<input type='submit' value='Go Back and Edit Again' onclick=\"javascript:history.go(-1)\">";
	// include the html form again.
	// include footer if you have one
	exit();
	}
}
*/

/* 
* Re-Format the html components For Easily Handling
* 
* http://us3.php.net/stripslashes
* http://us2.php.net/manual/en/function.htmlentities.php
*/
$domain = stripslashes(htmlentities($_POST['domain']));
$desired_username = stripslashes(htmlentities($_POST['desired_username']));
$intro = stripslashes(htmlentities($_POST['intro']));
$email = stripslashes(htmlentities($_POST['email']));
$age = stripslashes(htmlentities($_POST['age']));
$country = stripslashes(htmlentities($_POST['country']));
$city = stripslashes(htmlentities($_POST['city']));
$behs = stripslashes(htmlentities($_POST['behs']));
$theme = stripslashes(htmlentities($_POST['theme']));
$reason = stripslashes(htmlentities($_POST['reason']));
$referred = stripslashes(htmlentities($_POST['referred']));
$prev_host_name = stripslashes(htmlentities($_POST['prev_host_name']));
$prev_host_reason = stripslashes(htmlentities($_POST['prev_host_reason']));
$additional = stripslashes(htmlspecialchars($_POST['additional']));
$confirmation = stripslashes(htmlentities($_POST['confirmation']));
$forum_username = stripslashes(htmlentities($_POST['forum_username']));
$squote = stripslashes(htmlentities($_POST['squote']));

if ($prev_host_name == ""){
$prev_host_name = "na";
}

if ($prev_host_reason == ""){
$prev_host_reason = "na";
}

if ($additional == ""){
$additional = "na";
}

if ($squote == ""){
$squote = "na";
}

/*
* Now start the preview part
*
*
*/

if( isset( $_POST['generate_pre'] ) ){
echo "<form action='".$_SERVER['PHP_SELF']."?=done' method='post'>";

echo "<fieldset><legend>DEMO</legend>";
echo "To sign up free web hosting for you, please click : <a href=\"".$script_url."\">Free Web Hosting Request Form</a>";
echo "<br /><br />";

echo "<strong>Subject</strong> : Hosting Request <span style=\"color:blue; font-style:bold; font-weight:bold;\">".$domain."</span> <br />I would like to request free web hosting for my project from ".$company_name.". Please kindly find my application below.";
echo "<br /><br />";

echo "<strong>Your Desired Subdomain Name:</strong><br /><span style=\"color:blue;\">".$domain."</span>";
echo "<br /><br />";

echo "<strong>Account Username:</strong><br /><span style=\"color:blue;\">".$desired_username."</span>";
echo "<br /><br />";

echo "<strong>Introduction:</strong><br /><span style=\"color:blue;\">".bigboxotext($intro)."</span>";
echo "<br /><br />";

echo "<strong>Email Address:</strong><br /><span style=\"color:blue;\">".$email."</span>";
echo "<br /><br />";

echo "<strong>Age:</strong><br /><span style=\"color:blue;\">".$age."</span>";
echo "<br /><br />";

echo "<strong>Country Where I Live (current):</strong><br /><span style=\"color:blue;\">".$country."</span>";
echo "<br /><br />";

echo "<strong>City Where You Born:</strong><br /><span style=\"color:blue;\">".$city."</span>";
echo "<br /><br />";

echo "<strong>Your School Name</strong><br /><span style=\"color:blue;\">".$behs."</span>";
echo "<br /><br />";

echo "<strong>What is Your Website About:</strong><br /><span style=\"color:blue;\">".$theme."</span>";
echo "<br /><br />";

echo "<strong>What is Your Project About:</strong><br /><span style=\"color:blue;\">".$reason."</span>";
echo "<br /><br />";

echo "<strong>How I Found ".$company_shortname.":</strong><br /><span style=\"color:blue;\">".$referred."</span>";
echo "<br /><br />";

echo "<strong>My Previous Host:</strong><br /><span style=\"color:blue;\">".$prev_host_name."</span>";
echo "<br /><br />";

echo "<strong>Reason For Leaving My Previous Host:</strong><br /><span style=\"color:blue;\">".$prev_host_reason."</span>";
echo "<br /><br />";

echo "<strong>Additional Comments:</strong><br /><span style=\"color:blue;\">".bigboxotext($additional)."</span>";
echo "<br /><br />";

echo "<strong>I have read, understand, accept, and agree with the Terms Of Service, Acceptable Use Policy, and The Forum Rules:</strong><br /><span style=\"color:blue;\">".$confirmation."</span>";
echo "<br /><br />";

echo "<strong>Secret Quote:</strong><br /><span style=\"color:blue;\">".$squote."</span>";
echo "<br /><br />";

echo "<strong>Thank You,</strong><br /><span style=\"color:blue;\">".$forum_username."</span>";
echo "<br /><br />";

echo "</fieldset>";

echo "<br /><br />";
echo "<div style='padding-left: 20pt;'><input type=\"button\" onclick=\"javascript:history.go(-1)\" value=\"Go Back And Edit Again\" /> <input type=\"submit\" name=\"done\" value=\"Ok, Generate Now\"></div><br />";

//everything is ok so forward the data
echo "<input type=\"hidden\" name=\"domain\" value=\"".$domain."\">";
echo "<input type=\"hidden\" name=\"desired_username\" value=\"".$desired_username."\">";
echo "<input type=\"hidden\" name=\"intro\" value=\"".$intro."\">";
echo "<input type=\"hidden\" name=\"email\" value=\"".$email."\">";
echo "<input type=\"hidden\" name=\"age\" value=\"".$age."\">";
echo "<input type=\"hidden\" name=\"country\" value=\"".$country."\">";
echo "<input type=\"hidden\" name=\"city\" value=\"".$city."\">";
echo "<input type=\"hidden\" name=\"behs\" value=\"".$behs."\">";
echo "<input type=\"hidden\" name=\"theme\" value=\"".$theme."\">";
echo "<input type=\"hidden\" name=\"reason\" value=\"".$reason."\">";
echo "<input type=\"hidden\" name=\"referred\" value=\"".$referred."\">";
echo "<input type=\"hidden\" name=\"prev_host_name\" value=\"".$prev_host_name."\">";
echo "<input type=\"hidden\" name=\"prev_host_reason\" value=\"".$prev_host_reason."\">";
echo "<input type=\"hidden\" name=\"additional\" value=\"".$additional."\">";
echo "<input type=\"hidden\" name=\"confirmation\" value=\"".$confirmation."\">";
echo "<input type=\"hidden\" name=\"squote\" value=\"".$squote."\">";
echo "<input type=\"hidden\" name=\"forum_username\" value=\"".$forum_username."\">";

echo "</form> <br clear=\"all\" /></body></html>";

}


/*
* Now, let's start the done part
*
*
*/
if( isset( $_POST['done'] ) ) { 

//$textarea = $_POST['intro'];
//$textarea = bigboxotext($output);
//echo $_REQUEST['desired_username'];

echo "<fieldset><legend>SUBJECT</legend>";
echo "<input type=\"text\" id=\"txtfld\" onClick=\"SelectAll('txtfld');\" style=\"width:98%\" value = \"[Request]Free Web Hosting Request for ".$domain."\" />";
echo "</fieldset>";

if ($wysiwyg_warn=="yes"){
	echo "<br /><div style=\"font-size: 10pt; color: #FF0000; font-weight: bold; \">Warning: Your forum has WYSIWYG editor. You may paste the following body part but we recommand you to switch off WYSIWYG editor mode.";
	if ($wysiwyg_guide_url) { 
	echo " <a target=\"_blank\" href=\"$wysiwyg_guide_url\">Follow this guide for howto.</a>"; 
	}
echo "</div><br />";
}

if ($wysiwyg_warn!=="yes"){
	echo "<br /><br />";
}

echo "<fieldset><legend>BODY</legend>";

echo "<textarea id=\"txtarea\" onClick=\"SelectAll('txtarea');\" class=\"codecontainer\" name=\"body\" cols=\"100\" rows=\"25\">";
echo "
To sign up free web hosting for you, please click : [url=".$script_url."]Free Web Hosting Request Form[/url] [size=1][i] (Generated with [url=".$script_vendor."]".$script_name.$script_version."[/url])[/i][/size]

[b]Subject[/b] : Free Web Hosting Request [b][color=blue]".$domain."[/color][/b]
I would like to request free web hosting for my project from ".$company_name.". Please kindly find my application below.

[b]Your Desired Subdomain Name:[/b]
[color=blue]".$domain."[/color]

[b]Account Username:[/b]
[color=blue]".$desired_username."[/color]

[b]Introduction:[/b]
[color=blue]".$intro."[/color]

[b]Email Address:[/b]
[color=blue]".$email."[/color]

[b]Age:[/b]
[color=blue]".$age."[/color]

[b]Country Where I Live (current):[/b]
[color=blue]".$country."[/color]

[b]City Where You Born:[/b]
[color=blue]".$city."[/color]

[b]Your School Name:[/b]
[color=blue]".$behs."[/color]

[b]What is Your Website About:[/b]
[color=blue]".$theme."[/color]

[b]What is Your Project About:[/b]
[color=blue]".$reason."[/color]

[b]How I Found ".$company_shortname.":[/b]
[color=blue]".$referred."[/color]

[b]My Previous Host:[/b]
[color=blue]".$prev_host_name."[/color]

[b]Reason For Leaving My Previous Host:[/b]
[color=blue]".$prev_host_reason."[/color]

[b]Additional Comments:[/b]
[color=blue]".$additional."[/color]

[b]I have read, understand, accept, and agree with the Terms Of Service, Acceptable Use Policy, and The Forum Rules:[/b]
[color=blue]".$confirmation."[/color]

[b]Secret Quote:[/b]
[color=blue]".$squote."[/color]

[b]Thank You,[/b]
[color=blue]".$forum_username."[/color]";

echo "</textarea>";
//echo "</form>";
echo "</fieldset>";

echo "<br /><br />";
echo "<div style='padding-left: 20pt;'><input type=\"button\" onclick=\"javascript:history.go(-1)\" value=\"Go Back And Edit Again\" /> <input name=\"button\" type=\"button\" onclick=\"javascript:window.close();\" value=\"Close Window\" />";

}

if ($debug=="yes"){
	echo "<div><h2>Debugging Process:</h2><p>";
	print_r($_POST);
	echo "</p></div>";
}

include 'footer.php';
?>